import { getCommonStoragePrefix, getMemberPath } from '@fl/utils/env'
import Cookie from 'js-cookie'

export function openMallWindow() {
    window.open(import.meta.env.VITE_API_MALL_PATH, '_blank')
}
export function ToMember() {
    const tokenKey = `${getCommonStoragePrefix()}__access_token`

    const memberUrl = getMemberPath()
    if (memberUrl) {
        const token = Cookie.get(tokenKey) as string
        const path = `${memberUrl}/member`
        const iframe: any = document.createElement('iframe')
        iframe.style.width = '1px'
        iframe.style.height = '1px'

        // source 申请单来源 1后台录入 2集采商城 3招投标
        iframe.src = `${path}?token=${token}&source=3`

        console.log(`${path}?token=${token}&source=3`)
        document.body.append(iframe)
        iframe.onload = () => {
            console.log('path', path)
            window.open(path, '_block')
        }
    }
}
